<!--
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
	<meta charset="UTF-8">
	<title>文章内容</title>
	<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
	</link>
</head>

<body>
	<div class="container">
		<h1>文章内容发布</h1>
		<form action="#" th:action="@{/article/save}" th:if="${article!=null}" th:object="${article}" method="POST">
			<input type="hidden" name="id" th:value="*{id}" />
			<input type="text" th:field="*{title}" placeholder="标题" class="form-control mb-4 col-4">
			<select class="form-control select2 mb-4 col-4" id="typeId" name="typeId">
				<option value=""> &#45;&#45; 文章类型 &#45;&#45; </option>
				<option th:selected="${article.articletype.id eq c.id}" th:each="c:${typeList}" th:value="${c.id}"
					th:text="${c.type}" value="1">我读</option>
			</select>

			<textarea th:field="*{content}" rows="6" class="form-control mb-4 col-12" placeholder="文章内容"></textarea>
			<button type="submit" class="btn btn-info col-2">保存</button>
		</form>

		<form action="#" th:action="@{/article/save}" th:unless="${article!=null}" method="POST">
			<input type="text" name="title" placeholder="标题" class="form-control mb-4 col-4">
			<select class="form-control mb-4 col-4" id="typeId" name="typeId">
				<option value=""> &#45;&#45; 文章类型 &#45;&#45; </option>
				<option th:each="c:${typeList}" th:value="${c.id}"
					th:text="${c.type}" value="1">我读</option>
			</select>
			<textarea name="content" rows="6" class="form-control mb-4 col-12" placeholder="文章内容"></textarea>
			<button type="submit" class="btn btn-info col-2">保存</button>
		</form>

		<hr>

		<a th:href="@{/article/findAll}">返回文章类型列表</a>
	</div>
</body>

</html>
-->
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>文章内容发布</title>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <style>
        body {
            background: url('/img/addbackground.png') no-repeat center center fixed;
            background-size: cover;
            color: #343a40; /* 设置字体颜色 */
        }

        .container {
            max-width: 800px;
            margin: 2rem auto;
            padding: 2rem;
            box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
            background-color: #ffffff;
        }

        h1 {
            font-size: 2rem;
            color: #343a40;
        }

        .form-group {
            margin-bottom: 1.5rem;
        }

        .form-control {
            width: 100%;
            padding: 0.5rem 0.75rem;
            font-size: 1rem;
            border: 1px solid #ced4da;
            border-radius: 0.25rem;
            transition: border-color 0.2s;
        }

        .form-control:focus {
            border-color: #80bdff;
            box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
        }

        .btn-primary {
            background-color: #007bff;
            border-color: #007bff;
            font-size: 1rem;
            padding: 0.5rem 1rem;
        }

        .btn-primary:hover {
            background-color: #0056b3;
            border-color: #0056b3;
        }

        .btn-link {
            color: #007bff;
        }

        .btn-link:hover {
            color: #0056b3;
            text-decoration: underline;
        }

        .text-muted {
            font-size: 0.9rem;
        }

        .text-center {
            text-align: center;
        }

        .mb-4 {
            margin-bottom: 1.5rem;
        }
    </style>
</head>

<body>
<div class="container">
    <h1 class="text-center mb-4">文章内容发布</h1>
    <div th:if="${article!=null}">
        <form th:action="@{/article/save}" th:object="${article}" method="POST" class="mb-4">
            <input type="hidden" name="id" th:value="*{id}" />
            <div class="form-group">
                <label for="title">标题</label>
                <input type="text" th:field="*{title}" id="title" class="form-control" placeholder="请输入标题" required>
            </div>
            <div class="form-group">
                <label for="typeId">文章类型</label>
                <select class="form-control" id="typeId" name="typeId" required>
                    <option value="">-- 请选择文章类型 --</option>
                    <option th:each="c:${typeList}" th:value="${c.id}" th:text="${c.type}" th:selected="${article.articletype.id eq c.id}"></option>
                </select>
            </div>
            <div class="form-group">
                <label for="content">文章内容</label>
                <textarea th:field="*{content}" id="content" class="form-control" rows="6" placeholder="请输入文章内容" required></textarea>
            </div>
            <button type="submit" class="btn btn-primary btn-block">保存</button>
        </form>
    </div>
    <div th:unless="${article!=null}">
        <form th:action="@{/article/save}" method="POST" class="mb-4">
            <div class="form-group">
                <label for="newTitle">标题</label>
                <input type="text" name="title" id="newTitle" class="form-control" placeholder="请输入标题" required>
            </div>
            <div class="form-group">
                <label for="newTypeId">文章类型</label>
                <select class="form-control" id="newTypeId" name="typeId" required>
                    <option value="">-- 请选择文章类型 --</option>
                    <option th:each="c:${typeList}" th:value="${c.id}" th:text="${c.type}"></option>
                </select>
            </div>
            <div class="form-group">
                <label for="newContent">文章内容</label>
                <textarea name="content" id="newContent" class="form-control" rows="6" placeholder="请输入文章内容" required></textarea>
            </div>
            <button type="submit" class="btn btn-primary btn-block">保存</button>
        </form>
    </div>
    <hr>
    <a th:href="@{/article/findAll}" class="btn btn-link text-left">返回文章类型列表</a>
</div>
</body>

</html>